home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / Assoc.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  97 lines

  1. /* Assoc.c -- implementation of key-value association
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Reearch and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet: kgorlen@alw.nih.gov
  20.     September, 1985
  21.  
  22. Function:
  23.  
  24. Objects of class Assoc associate a key object with a value object.  They
  25. are used to implement Dictionaries, which are Sets of Associations.
  26.  
  27. $Log:    Assoc.c,v $
  28.  * Revision 3.0  90/05/20  00:19:01  kgorlen
  29.  * Release for 1st edition.
  30.  * 
  31. */
  32.  
  33. #include "Assoc.h"
  34. #include "nihclIO.h"
  35.  
  36. #define    THIS    Assoc
  37. #define    BASE    LookupKey
  38. #define BASE_CLASSES BASE::desc()
  39. #define MEMBER_CLASSES
  40. #define VIRTUAL_BASE_CLASSES
  41.  
  42. DEFINE_CLASS(Assoc,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Assoc.c,v 3.0 90/05/20 00:19:01 kgorlen Rel $",NULL,NULL);
  43.  
  44. Assoc::Assoc(Object& newKey, Object& newValue) : BASE(newKey)
  45. {
  46.     avalue = &newValue;
  47. }
  48.  
  49. Object* Assoc::value() { return avalue; }
  50.  
  51. const Object* Assoc::value() const { return avalue; }
  52.  
  53. Object* Assoc::value(Object& newvalue)
  54. {
  55.     Object* temp = avalue;
  56.     avalue = &newvalue;
  57.     return temp;
  58. }
  59.  
  60. void Assoc::deepenShallowCopy()
  61. {
  62.     BASE::deepenShallowCopy();
  63.     avalue = avalue->deepCopy();
  64. }
  65.  
  66. Assoc::Assoc(OIOin& strm)
  67. :
  68. #ifdef MI
  69.     Object(strm),
  70. #endif
  71.     BASE(strm)
  72. {
  73.     avalue = Object::readFrom(strm);
  74. }
  75.  
  76. void Assoc::storer(OIOout& strm) const
  77. {
  78.     BASE::storer(strm);
  79.     avalue->storeOn(strm);
  80. }
  81.  
  82. Assoc::Assoc(OIOifd& fd)
  83. :
  84. #ifdef MI
  85.     Object(fd),
  86. #endif
  87.     BASE(fd)
  88. {
  89.     avalue = Object::readFrom(fd);
  90. }
  91.  
  92. void Assoc::storer(OIOofd& fd) const
  93. {
  94.     BASE::storer(fd);
  95.     avalue->storeOn(fd);
  96. }
  97.